package qgs.zisu.javaconcurrency.javaconcurrency.chapter6_forceOrGracefulClose;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/26 10:12
 * @Version 1.0
 */
public class ThreadCloseForce {
    private static class Worker extends Thread{
        private boolean flag = true;
        @Override
        public void run(){
             while (flag){
                 // connection
                 // 如果线程在这里 阻塞住了，即使我外部通过flag开关来 关它，线程在这里阻塞住了，也关不了
             }
                //-------------下面写业务逻辑----------
        }
    }

    public static void main(String[] args) {
        Worker worker = new Worker();
        worker.start();

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        worker.interrupt();
    }
}
